<template>
    <div>
        <h1>登录页面</h1>

        <van-field type="text" label="请输入用户名" placeholder="" v-model="username"/>
        <van-field type="password" label="请输入密码" placeholder="" v-model="password"/>

        <van-button type="primary" @click="denglu">确认登录</van-button>

    </div>
</template>

<script>
export default {
   data () {
      return {
            username:'',
            password:''
      };
   },

    methods: {  
            //登录
            denglu:function(){
                this.axios.post(this.localhost+'denglu/',this.qs.stringify({username:this.username,password:this.password}))
                .then(res=>{
                    console.log(res);
                    if(res.data.code == 200){
                        this.$toast.success('登录成功')
                        localStorage.setItem('test_username',res.data.username)
                        localStorage.setItem('test_uid',res.data.id)
                        this.$router.push('/test_dingdan/')
                    }else{
                        this.$toast.fail('登录失败')
                    }
                })
            }
       },

    computed: {

       },

    created () {

       },

    mounted() {

       },

    components: {

       }
}
</script>
<style lang='css' scoped>

</style>